<template>
	<div>
		<el-row>
			<el-col :span="24">
				<div class="grid-content bg-purple-dark"></div>
			</el-col>
		</el-row>
		<el-row>
			<el-col :span="12">
				<div class="grid-content bg-purple"></div>
			</el-col>
			<el-col :span="12">
				<div class="grid-content bg-purple"></div>
			</el-col>
		</el-row>
		<el-row>
			<el-col :span="6" class="grid-content bg-purple">1</el-col>
			<el-col :span="6" class="grid-content bg-purple">2</el-col>
			<el-col :span="6" class="grid-content bg-purple">1</el-col>
			<el-col :span="6" class="grid-content bg-purple">2</el-col>
		</el-row>

		<el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange"
			>全选</el-checkbox
		>
		<div style="margin: 15px 0"></div>
		<el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
			<el-checkbox v-for="city in cities" :label="city" :key="city">{{ city }}</el-checkbox>
		</el-checkbox-group>
	</div>
</template>

<script>
	export default {
		name: 'layout',
		data() {
			return {
				key: 'value',
				checkAll: false,
				checkedCities: ['上海', '北京'],
				cities: ['上海', '北京', '广州', '深圳'],
				isIndeterminate: true
			}
		},
		methods: {
			name() {
				this.$message({
					message: 'text',
					type: 'info'
				})
			},
			handleCheckAllChange(val) {
				this.checkedCities = val ? this.cities : []
				this.isIndeterminate = false
			},
			handleCheckedCitiesChange(value) {
				let checkedCount = value.length
				this.checkAll = checkedCount === this.cities.length
				this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length
			}
		}
	}
</script>

<style lang="scss" scoped>
	.el-row {
		margin-bottom: 20px;
		&:last-child {
			margin-bottom: 0;
		}
	}
	.el-col {
		border-radius: 4px;
	}
	.bg-purple-dark {
		background: #99a9bf;
	}
	.bg-purple {
		background: #d3dce6;
	}
	.bg-purple-light {
		background: #e5e9f2;
	}
	.grid-content {
		border-radius: 4px;
		min-height: 36px;
	}
	.row-bg {
		padding: 10px 0;
		background-color: #f9fafc;
	}
</style>
